package com.yida.system.api;

import com.yida.common.core.constant.SecurityConstants;
import com.yida.common.core.constant.ServiceNameConstants;
import com.yida.common.core.domain.R;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.system.api.domain.SysUserCommunity;
import com.yida.system.api.domain.request.BindCommunityRequest;
import com.yida.system.api.domain.request.RegisterBindRequest;
import com.yida.system.api.domain.request.SysUserOutsideOfficerRemoveRequest;
import com.yida.system.api.domain.request.SysUserQueryRequest;
import com.yida.system.api.factory.RemoteUserFallbackFactory;
import com.yida.system.api.factory.RemoteUserOutsideOfficerFallbackFactory;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Description 外网用户管理
 * @Author wws
 * @Date 2023-06-17
 */
@FeignClient(contextId = "remoteUserOutsideOfficerService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserOutsideOfficerFallbackFactory.class, configuration = FeignAutoConfiguration.class)
public interface RemoteUserOutsideOfficerService {

    /**
     * 内部获取用户列表
     * @param request 请求参数
     * @param source
     * @return
     */
    @GetMapping("/outsideOfficer/innerList")
    R<TableDataInfo> innerList(SysUserQueryRequest request, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 内部绑定项目
     * @param request 请求参数
     * @param source
     * @return
     */
    @PostMapping("/outsideOfficer/innerBindCommunity")
    R innerBindCommunity(@RequestBody @Valid BindCommunityRequest request,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 内部查询已绑定项目
     * @param userId 用户主键
     * @param source
     * @return
     */
    @GetMapping("/outsideOfficer/innerListCommunities/{userId}")
    R<List<SysUserCommunity>> innerGetBindCommunities(@PathVariable("userId") Long userId,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 内部注册用户并绑定项目
     * @param request 请求参数
     * @param source
     * @return
     */
    @PostMapping("/outsideOfficer/innerRegisterBind")
    R innerRegisterAndBind(@RequestBody RegisterBindRequest request,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 内部删除用户
     * @param request 请求参数
     * @param source
     * @return
     */

    @PostMapping("/outsideOfficer/innerRemoveOutsideUser")
    R innerRemoveOutsideUser(@RequestBody @Validated SysUserOutsideOfficerRemoveRequest request,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
